<?php
/**
 * Created by PhpStorm.
 * User: this
 * Date: 2018/12/28
 * Time: 11:16
 */
namespace app\admin\model;
use think\Model;

class Message extends Model{
    /**
     * @param $condition
     * @param string $field
     * @param string $sort
     * @param int $page
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getPage($condition,$field = '*',$sort = 'mess_id desc',$page = 10){
        return $this->name('mess')->field($field)->cache(true)->where($condition)->order($sort)->paginate($page);
    }

    public function del($condition){
        return $this->name('mess')->where($condition)->delete();
    }

    /**
     * @param $condition
     * @param string $field
     * @return array|null|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getOne($condition,$field = '*'){
        return $this->name('mess')->field($field)->where($condition)->find();
    }
}